package com.woniuxy.commons.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class TransferOrderRandom {
    /**
     * 订单前缀
     */
    private static final String ORDERPREFIX = "huanglei";
    /**
     * 时间戳
     */
    private static final String FORMAT = "yyyyMMddHHmmss";
    /**
     * 数字随机
     */
    public static final String numberChar = "0123456789";

    /**
     * 随机数字
     */
    public static final int numberFor = 5;
    

    public synchronized static String createOrderSnRandom() {
        return AbstractOrderSequenceRandomInner.createOrderSnRandomInner();
    }

    /**
     * 创建订单号<svsp + yyyy-mm-dd + Random>
     *
     */
    private final static class AbstractOrderSequenceRandomInner {
        private synchronized static String createOrderSnRandomInner() {
            SimpleDateFormat sdf = new SimpleDateFormat(FORMAT);
            StringBuffer sb = new StringBuffer();
            Random random = new Random();
            for (int i = 0; i < numberFor; i++) {
                sb.append(numberChar.charAt(random.nextInt(numberChar.length())));
            }
            return  sdf.format(new Date()) + sb.toString();
        }
    }

    public static void main(String[] args) {
        System.out.println(TransferOrderRandom.createOrderSnRandom());
    }
    
}